<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <title>パソコン注文状況一覧</title>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="/css/bootstrap.min.css" rel="stylesheet" media="screen" />
    <link href="/css/style.css" rel="stylesheet" media="screen" />

</head>
<script src="/js/jquery-3.4.1.min.js"></script>
<body>

<div class="container">
<!--    <form name="form" method="post" action="/TPNUA2">-->
        <div align="right" class="times"><span>日付</span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="times"></span></div><br />
        <div><span class="tittle">＜＜</span><span class="tittleValue">パソコン注文状況一覧</span><span class="tittle">＞＞</span></div>
        <br />
        <div>
            <table id="table" width="100%">
                <tr id="maps" th:each = "map : ${maps}">
                    <td><input type="text" th:value = "*{map.key.name}" /></td>
                    <td><input type="text" th:value = "*{map.key.price}"/></td>
                    <td><input type="text" th:value = "*{map.key.stockNum}"/></td>
                    <td><input type="text" th:value = "*{map.value}"/></td>
                </tr>
<!--                <tr>-->
<!--                    <th width="25%">営業店名</th>-->
<!--                    <th width="30%">製品名</th>-->
<!--                    <th width="15%">単価</th>-->
<!--                    <th width="15%">在庫数</th>-->
<!--                    <th width="15%">注文数</th>-->
<!--                </tr>-->
<!--                <tr>-->
<!--                    <td>渋谷本店  </td>-->
<!--                    <td>VS133-128MX    </td>-->
<!--                    <td class="right">￥6,280</td>-->
<!--                    <td class="right">83 </td>-->
<!--                    <td class="right">1</td>-->
<!--                </tr>-->
<!--                <tr>-->
<!--                    <td>          </td>-->
<!--                    <td>               </td>-->
<!--                    <td class="right"></td>-->
<!--                    <td class="right">   </td>-->
<!--                    <td class="right"> </td>-->
<!--                </tr>-->
<!--                <tr>-->
<!--                    <td>          </td>-->
<!--                    <td>               </td>-->
<!--                    <td class="right"></td>-->
<!--                    <td class="right">   </td>-->
<!--                    <td class="right"> </td>-->
<!--                </tr>-->
<!--                <tr>-->
<!--                    <td>          </td>-->
<!--                    <td>               </td>-->
<!--                    <td class="right"></td>-->
<!--                    <td class="right">   </td>-->
<!--                    <td class="right"> </td>-->
<!--                </tr>-->
<!--                <tr>-->
<!--                    <td>          </td>-->
<!--                    <td>               </td>-->
<!--                    <td class="right"></td>-->
<!--                    <td class="right">   </td>-->
<!--                    <td class="right"> </td>-->
<!--                </tr>-->
<!--                <tr>-->
<!--                    <td>          </td>-->
<!--                    <td>               </td>-->
<!--                    <td class="right"></td>-->
<!--                    <td class="right">   </td>-->
<!--                    <td class="right"> </td>-->
<!--                </tr>-->
<!--                <tr>-->
<!--                    <td>          </td>-->
<!--                    <td>               </td>-->
<!--                    <td class="right"></td>-->
<!--                    <td class="right">   </td>-->
<!--                    <td class="right"> </td>-->
<!--                </tr>-->
<!--                <tr>-->
<!--                    <td>          </td>-->
<!--                    <td>               </td>-->
<!--                    <td class="right"></td>-->
<!--                    <td class="right">   </td>-->
<!--                    <td class="right"> </td>-->
<!--                </tr>-->
<!--                <tr>-->
<!--                    <td>          </td>-->
<!--                    <td>               </td>-->
<!--                    <td class="right"></td>-->
<!--                    <td class="right">   </td>-->
<!--                    <td class="right"> </td>-->
<!--                </tr>-->
<!--                <tr>-->
<!--                    <td>          </td>-->
<!--                    <td>               </td>-->
<!--                    <td class="right"></td>-->
<!--                    <td class="right">   </td>-->
<!--                    <td class="right"> </td>-->
<!--                </tr>-->
            </table><br />
            <div align="right" class="count"><span>合計</span>&nbsp;<input type="text" id="sum" th:text="'￥'+${sum}" disabled="disabled"/></div><br />
            <br />
            <div class="bottomText">次処理⇒　１：注文確定 ２：注文中断&nbsp;
                <input type="text" autocomplete="off" class="input2" name="choose" value="1" id="choose" onkeydown="if(event.keyCode==13){event.keyCode=0;event.returnValue=false;}" />
            </div><div class="bottomSubmit"><input type="button" id="check" value="送信" /></div>
            <input type="button" value="Cancel" onclick="document.form.IN_CONTINUE.value='0';document.form.submit();" style="display:none" />
            <input type="submit" value="Next" onclick="comeback()" />
<!--            <input type="hidden" name="TRNS_NAME" value="0000001" />-->
<!--            <input type="hidden" name="IN_TRNM" value="TRNUA4" />-->
<!--            <input type="hidden" name="IN_CONTINUE" value="1" />-->
<!--            <input type="hidden" name="TRNS_STATUS" value="01" />-->
        </div>
<!--    </form>-->
</div>
<script type="text/javascript" th:inline="javascript">
    window.onload = function()
    {
        document.getElementById("choose").select();
    }
    var trLength = $('tr').length-1;
    for(var i=0;trLength>i;i++){
      var stock = $('table tr').find('td:eq(3)')[i].innerHTML;
      if(stock.replace(/\s/g,'')!=""){
        while(3>stock.replace(/\s/g,'').length){
          stock="0"+stock.replace(/\s/g,'');
           }
        }
      $('table tr').find('td:eq(3)')[i].innerHTML = stock;
    }
    var date = new Date();
    var yyyy = date.getFullYear();
    var mm = date.getMonth() + 1;
    if(10 > mm){
      mm = "0" + mm;
    }
    var dd = date.getDate();
    if(10 > dd){
      dd = "0" + dd;
    }
    var compare = yyyy+mm+dd; //string
    var reiwa = '20190501'; //2019年5月1日より令和
    var mmdd, yy;
      if (reiwa >compare){
          yy = yyyy-1988;
      } else {
          yy = yyyy-2018;
      }
      if (10 > yy){
          yy = "0"+yy;
      }
      mmdd = "0" + mm+"月"+dd+"日";
      if (reiwa >compare){
          document.getElementById("times").innerHTML =  yy+"."+mm+"."+dd; // 平成24年05月09日
      } else {
          document.getElementById("times").innerHTML =  yy+"."+mm+"."+dd; // 令和02年05月09日
      }
      $("#check").click(function(){
          if($("#choose").val() == "2"){
            $("input[value='Cancel']").click();
          }else if($("#choose").val() == "1"){
            $("input[type='submit']").click();
          }else{
            $("#choose").val("!");
          }
        });
     // var totalRow = 0;
     // $('#table tr').each(function() {
     //                 var price =$(this).find('td:eq(2)').text().replace(/,/g,'').substr(1);
     //                var order =$(this).find('td:eq(4)').text();
     //                totalRow += Number(price) * Number(order);
     //    });
     //     var regExpInfo = /(\d{1,3})(?=(\d{3})+(?:$|\.))/g;
     //     var ret ="￥"+totalRow.toString().replace(regExpInfo, "$1,");
     //    document.getElementById("sum").value = ret;

    function comeback() {
        if ($("#sum").value = 0){
            location.href = "/comeback1"
        }else {
            location.href = "/decrease"
        }
    }
  </script>
</body>
</html>